package kotlin01

//map映射 分为可变不可变
//入口函数
fun main() {
    //可变mutableMapOf
    val m2 = mutableMapOf(
        "pig" to "猪",
        "cat" to "猫",
        "dog" to "狗",
        "mouse" to "老鼠"
    )
    //1、新增
    m2["person"] = "人"
    println(m2["pig"])
    //2、修改
    m2["dog"] = "小狗狗"
    println(m2["dog"])
    //3、删除
    m2.remove("mouse")
    println(m2)


    /*
        //不可变map
        val m1 = mapOf(
            "breakfast" to "早餐",
            "lunch" to "午餐",
            "dinner" to "晚餐"
        )
        println(m1["lunch"])
        println(m1["eat"])//取不到值的
    //    println(m1["dinner"])="" //不能修改 直接报错了
        m1.forEach { key, value -> println("$key:$value") } //循环遍历*/
}
